﻿using System;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace ChinaTax.LeQi
{
    public class InvoiceUploadRequest : Request<InvoiceUploadResponse>
    {
        public InvoiceUploadRequest()
        {
            ServiceCode = "QDFPSC";
        }

        [JsonProperty("nsrsbh")]
        public string TaxNo { get => LeQiConfig.TaxNo; }

        public List<Invoice> List { get; set; } = new List<Invoice>();

        protected override string GetBody()
        {
            return JsonConvert.SerializeObject(List);
        }
    }

    public class Invoice
    {
        [JsonProperty("ptbh")]
        public string PlatformNo { get => LeQiConfig.LeQiId; }

        [JsonProperty("fphm")]
        public string InvoiceNumber { get; set; }

        [JsonProperty("lzfpbz")]
        public string RedFlag { get; set; }

        [JsonProperty("qyDm")]
        public string DistrictCode { get; set; }

        [JsonProperty("xsfnsrsbh")]
        public string SellerTaxNo { get; set; }

        [JsonProperty("xsfmc")]
        public string SellerName { get; set; }

        [JsonProperty("gmfmc")]
        public string PurchaserName { get; set; }

        [JsonProperty("hjje")]
        public string Amount { get; set; }

        [JsonProperty("hjse")]
        public string Tax { get; set; }

        [JsonProperty("jshj")]
        public string HasTaxAmount { get; set; }

        [JsonProperty("kpr")]
        public string Invoicer { get; set; }

        [JsonProperty("kprq")]
        public string InvoiceDate { get; set; }

        [JsonProperty("dylzfphm")]
        public string BlueInvoiceNumber { get; set; }

        [JsonProperty("hzqrxxdbh")]
        public string RedConfirmNo { get; set; }

        [JsonProperty("hzqrduuid")]
        public string RedConfirmUuid { get; set; }

        [JsonProperty("bz")]
        public string Remark { get; set; }

        [JsonProperty("ip")]
        public string Ip { get; set; }

        [JsonProperty("macdz")]
        public string Mac { get; set; }

        [JsonProperty("fpmxList")]
        public List<InvoiceDetail> Detail { get; set; } = new List<InvoiceDetail>();
    }

    public class InvoiceDetail
    {
        [JsonProperty("mxxh")]
        public string Line { get; set; }

        [JsonProperty("dylzfpmxxh")]
        public string BlueInvoiceLine { get; set; }

        [JsonProperty("sphfwssflhbbm")]
        public string TaxClassCode { get; set; }

        [JsonProperty("hwhyslwfwmc")]
        public string Name { get; set; }

        [JsonProperty("spfwjc")]
        public string ShortName { get; set; }

        [JsonProperty("xmmc")]
        public string Item { get; set; }

        [JsonProperty("ggxh")]
        public string Specs { get; set; }

        [JsonProperty("dw")]
        public string Unit { get; set; }

        [JsonProperty("dj")]
        public string Price { get; set; }

        [JsonProperty("sl")]
        public string Qty { get; set; }

        [JsonProperty("je")]
        public string Amount { get; set; }

        [JsonProperty("slv")]
        public string TaxRate { get; set; }

        [JsonProperty("se")]
        public string Tax { get; set; }

        [JsonProperty("hsje")]
        public string HasTaxAmount { get; set; }

        [JsonProperty("fphxz")]
        public string DetailType { get; set; }

        [JsonProperty("yhzcbs")]
        public string TaxPolicy { get; set; }
    }

    public class InvoiceUploadResponse : Response
    {
        [JsonProperty("sllsh")]
        public string No { get; set; }
    }

}
